package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.DepModeInfo;
import com.softer.wxzj.service.DepModeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author ludexing
 * @Date 2019-6-25 20:31
 */
@RestController
@RequestMapping("/depModeInfo")
public class DepModeInfoController {

    @Autowired
    private DepModeInfoService depModeInfoService;

    /**
     * 新增 缴存模式
     *
     * @param depModeInfo
     * @return
     */
    @RequestMapping("/add")
    @LogRecord(description = "新增缴存模式", operationUnit = LogOperationUnit.DEP_MODE, operationType = LogOperationType.INSERT)
    public CommonResult add(DepModeInfo depModeInfo) {
        return depModeInfoService.insert(depModeInfo);
    }

    /**
     * 更新缴存模式
     *
     * @param depModeInfo
     * @return
     */
    @RequestMapping("/update")
    @LogRecord(description = "修改缴存模式", operationUnit = LogOperationUnit.DEP_MODE, operationType = LogOperationType.UPDATE)
    public CommonResult update(DepModeInfo depModeInfo) {
        return depModeInfoService.update(depModeInfo);
    }

    @RequestMapping("/enable")
    @LogRecord(description = "缴存模式 启用 停用", operationUnit = LogOperationUnit.DEP_MODE, operationType = LogOperationType.UPDATE)
    public CommonResult enable(DepModeInfo depModeInfo) {
        return depModeInfoService.enable(depModeInfo);
    }

    @RequestMapping("/getList")
    @LogRecord(description = "缴存模式列表", operationUnit = LogOperationUnit.DEP_MODE, operationType = LogOperationType.SELECT)
    public PageInfo<DepModeInfo> getList(Page page, DepModeInfo depModeInfo) {
        return depModeInfoService.getList(page, depModeInfo);
    }

    @RequestMapping("/getListNoPage")
    @LogRecord(description = "缴存模式列表不分页", operationUnit = LogOperationUnit.DEP_MODE, operationType = LogOperationType.SELECT)
    public List<DepModeInfo> getListNoPage(String modeType) {
        return depModeInfoService.getListNoPage(modeType);
    }


    @RequestMapping("/getInfo")
    @LogRecord(description = "缴存模式单个", operationUnit = LogOperationUnit.DEP_MODE, operationType = LogOperationType.SELECT)
    public DepModeInfo getInfo(String id) {
        return depModeInfoService.getInfo(id);
    }

    /**
     * 删除缴存模式
     *
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    @LogRecord(description = "缴存模式删除", operationUnit = LogOperationUnit.DEP_MODE, operationType = LogOperationType.DELETE)
    public CommonResult delete(String id) {
        return depModeInfoService.delete(id);
    }


    @RequestMapping("/getListByHouseId")
    @LogRecord(description = "根据house匹配缴存模式列表", operationUnit = LogOperationUnit.DEP_MODE, operationType = LogOperationType.SELECT)
    public List<DepModeInfo> getListByHouseId(String houseId) {
        return depModeInfoService.getListByHouseId(houseId);
    }

    @RequestMapping("/selectByAllChange")
    @LogRecord(description = "查询缴存", operationUnit = LogOperationUnit.DEP_MODE, operationType = LogOperationType.SELECT)
    public List<DepModeInfo> selectByAllChange(DepModeInfo depModeInfo) {
        return depModeInfoService.selectByAllChange(depModeInfo);
    }
}
